package com.mingqi.enetconnected.primary.mytask.adapter;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingqi.enetconnected.R;
import com.mingqi.enetconnected.primary.mytask.entity.UserInfoMultipleEntity;
import com.mingqi.enetconnected.view.decoration.DividerGridItemDecoration;

import java.util.ArrayList;
import java.util.List;


/**
 * @author li
 * @version 1.0
 * @describe
 * @WeChat 18571658038
 * @date 2018/9/5 星期三.
 */

public class UserInfoAdapter extends BaseMultiItemQuickAdapter<UserInfoMultipleEntity,BaseViewHolder> {

    public UserInfoAdapter(List<UserInfoMultipleEntity> list) {
        super(list);

        addItemType(UserInfoMultipleEntity.USER_INFO, R.layout.item_user_info);
        addItemType(UserInfoMultipleEntity.EQUITY_DATA, R.layout.item_equity_data);
        addItemType(UserInfoMultipleEntity.PAYMENT_INFO, R.layout.item_payment_info);
        addItemType(UserInfoMultipleEntity.SERVICE_CONTENT, R.layout.item_service_content);
        addItemType(UserInfoMultipleEntity.REPLENISH_STATE, R.layout.item_replenish_state);
        addItemType(UserInfoMultipleEntity.ORDER_SOURCE, R.layout.item_order_source);
        addItemType(UserInfoMultipleEntity.ORDER_OPERATE, R.layout.item_order_operate);
    }

    @Override
    protected void convert(BaseViewHolder helper, UserInfoMultipleEntity item) {

        int type = helper.getItemViewType();
        switch (type) {
            case UserInfoMultipleEntity.EQUITY_DATA:

                TextView tvEquityCheck = helper.getView(R.id.tv_equity_check);
                helper.addOnClickListener(R.id.tv_equity_check);
                String content = item.getContent();
                tvEquityCheck.setText(content);
                break;

            case UserInfoMultipleEntity.PAYMENT_INFO:

                helper.addOnClickListener(R.id.tv_scan_sign);
                helper.addOnClickListener(R.id.tv_assist_sign);
                helper.addOnClickListener(R.id.rtv_pay);

                break;

            case UserInfoMultipleEntity.SERVICE_CONTENT:

                helper.addOnClickListener(R.id.iv_service_message);
                helper.addOnClickListener(R.id.iv_service_phone);
                break;

            case UserInfoMultipleEntity.REPLENISH_STATE :

                RecyclerView rvImage = helper.getView(R.id.rv_image);

                List<String> stringList = new ArrayList<>();
                for (int i = 0; i < 5; i++) {

                    stringList.add("");
                }

                ReplenishStateImgAdapter adapter = new ReplenishStateImgAdapter(stringList);
                rvImage.setAdapter(adapter);
                rvImage.addItemDecoration(new DividerGridItemDecoration(rvImage.getContext()));
                rvImage.setLayoutManager(new GridLayoutManager(rvImage.getContext(),4));

                break;

            case UserInfoMultipleEntity.ORDER_OPERATE:
                helper.addOnClickListener(R.id.rtv_cancel);
                helper.addOnClickListener(R.id.rtv_go_sign);
                helper.addOnClickListener(R.id.rtv_change_dispatch);
                helper.addOnClickListener(R.id.rtv_cancel);
            default:
                break;
        }
    }
}
